# Core Library Description

## Introduction

The core library is used to implement the math behind Xoron cryptography.

The library defines how to generate and manipulate core data structures.

## Includes

Library header.

[comment]: <> (../inc/xrn_core.h)
```Xoronos_C
#ifndef XORON_CORE_LIB_H
#define XORON_CORE_LIB_H
```

[comment]: <> (../inc/xrn_core.h)
```Xoronos_C
#include <stdio.h>
#include <pthread.h>
#include "xrn_settings.h"
#include "xrn_common.h"
#include "xrn_arithmetic.h"
#include "xrn_encoder.h"
```

## Type Definitions

### xrn_crypto_extra_settings_t

[comment]: <> (../inc/xrn_core.h)
```Xoronos_C
typedef struct xrn_crypto_extra_settings_t {
    char rnd_str[XRN_BUFF_SIZE];
    uint8_t crc_bytes;
    uint8_t state_size;
    uint8_t thread_enable;
    uint32_t component_id;
    XBIT_TYPE const_exec_time;
    xrn_interface_settings_t encoding_settings;
} xrn_crypto_extra_settings_t;  
```

The **rnd_str** field is used to affect the randomness with a string.

The **crc_bytes** field defines the size of the checksum when performing encryption/decryption.

The **state_size** field defines the number of points (xnum_t numbers) inside a block.

The **thread_enable** field defines if the cross traverses (the heavy part of the computation) will be performed in parallel.

The **component_id** field can define the "id" of the program that uses the library.

The **const_exec_time** field defines if the cross traverses (the heavy part of the computation) will be performed with a constant time.

The **encoding_settings** field defines if the encoding interface initialization settings.

### xrn_point_t

[comment]: <> (../inc/xrn_core.h)
```Xoronos_C
typedef struct xrn_point_t {
   xnum_t  point;
} xrn_point_t;  
```

The **point** field is the value of the point.

### xgenesis_base_t

[comment]: <> (../inc/xrn_core.h)
```Xoronos_C
typedef struct xgenesis_base_t {
   uint8_t  base_vector [XNBYTES_ORIGIN];
} xgenesis_base_t;
```

The **base_vector** field defines a compressed version of a square matrix.

### xrn_base_t

[comment]: <> (../inc/xrn_core.h)
```Xoronos_C
typedef struct xrn_base_t {
   xmat_t base_matrix;
   xnum_t sign_vector; 
} xrn_base_t;  
```

The **base_matrix** field defines the square matrix.

The **sign_vector** is used to change the dead code for the xoron base.


### xrn_vector_t

[comment]: <> (../inc/xrn_core.h)
```Xoronos_C
typedef struct xrn_vector_t {
   xrn_base_t xbase;
   xnum_t     entry_point; 
} xrn_vector_t; 
```

The **xbase** field defines the xoron base.

The **entry_point** is used to insert the dead code in the traverse functions.

### xrn_matrix_compressed_t

[comment]: <> (../inc/xrn_core.h)
```Xoronos_C
typedef struct xrn_matrix_compressed_t {
   xgenesis_base_t    xgenesis_base;
   xnum_t             change_of_sign; 
   xnum_t             change_of_base; 
} xrn_matrix_compressed_t;
```

The **xgenesis_base** field defines the xoron base.

The **change_of_sign** is used to insert the dead code in the traverse functions.

The **change_of_base** is used to permute the xgenesis_base.

### xrn_matrix_t

[comment]: <> (../inc/xrn_core.h)
```Xoronos_C
typedef struct xrn_matrix_t {
   xrn_vector_t xvector [XNBITS];
   xnum_t         xrn_dead_code; 
} xrn_matrix_t;
```

The **xvertor** field is used to define the "matrix" of xoron vectors.

The **xrn_dead_code** field is used to store the dead code.


### cmtraverse_t

The data structure is used to compute parallelly the xoron matrix traverse function.

[comment]: <> (../inc/xrn_core.h)
```Xoronos_C
typedef struct cmtraverse_t {
   xrn_matrix_t * xm;
   xnum_t * p;
   xnum_t * d;
   xnum_t * dst;
   int * linear;
   uint8_t * constant_execution;
   uint8_t * force_linearity;
   uint8_t * check_sparcity;
} cmtraverse_t;
```

The **xm** xoron matrix.

The **p** starting point.

The **d** distance.

The **dst** destination point.

The **linear** is used to check if a non linear error occurred.

The **constant_execution** is used to set if the computation should be constant.

The **force_linearity** is perform linearity safety checks.

### traverse_opt_t

The data structure is used to optimize the xoron vector traverse.
Fields in this data structure are internal variables used in the xoron vector traverse function.

[comment]: <> (../inc/xrn_core.h)
```Xoronos_C
typedef struct traverse_opt_t {
    xnum_t tmp1;
    xnum_t tmp0;
    XBIT_TYPE b0, b1, bit;
    uint16_t i, j;
} traverse_opt_t;
```

## Extra Includes

[comment]: <> (../inc/xrn_core.h)
```Xoronos_C
#include "xrn_core_backend.h"
```

## Traverse Functions

### xrn_vector_traverse

**Description:**

The **xrn_vector_traverse** is used to traverse a xoron vector data structure.

The function can generate $2^N$ different numbers where N is the bit width of the xnum_t data structure. 

Internally the function does not declare new variables. 
The function returns 0 if the non linear exception is detected and 1 if otherwise.

**Function declaration:**

[comment]: <> (../inc/xrn_core.h)
```Xoronos_C
int xrn_vector_traverse ( 
    xrn_vector_t * xv,
    xnum_t * dc,
    xnum_t * p,
    xnum_t * dst,
    traverse_opt_t * tmp
);
```

**Arguments description:**

> **input:** xv    $\rightarrow$ The xv is the xoron vector pointer. \
> **input:** dc    $\rightarrow$ The dc is the dead code pointer. \
> **input:** p     $\rightarrow$ The p is the input point pointer. \
> **output:** dst   $\rightarrow$ The dst is the pointer to the destination point. \
> **inout:**  tmp   $\rightarrow$ Temporary variables used to perform computation. 

### xrn_matrix_traverse

**Description:**

The **xrn_matrix_traverse** is used to traverse with xoron matrix data structure.

The function can generate $2^N$ different numbers where N is the bit width of the xnum_t data structure. 


**Function declaration:**

[comment]: <> (../inc/xrn_core.h)
```Xoronos_C
int xrn_matrix_traverse ( 
    xrn_matrix_t * xm,
    xnum_t * p,
    xnum_t * d,
    xnum_t * dst,
    uint8_t * constant_execution, 
    uint8_t * force_linearity,
    uint8_t * check_sparcity
);
```

**Arguments description:**

> **input:** xm                 $\rightarrow$ The xm is the xoron matrix pointer. \
> **input:** p                  $\rightarrow$ The p is the input point pointer. \
> **input:** d                  $\rightarrow$ The d is the distance from p. \
> **output:** dst                $\rightarrow$ The dst is the pointer to the destination point. \
> **input:** constant_execution $\rightarrow$ If the function should be executed with a constant time. \
> **input:** force_linearity    $\rightarrow$ If the function should detect and exit if a non linear error occurs. \
> **input:** check_sparcity     $\rightarrow$ If the function should check the distance to protect the permutation layer. 

[comment]: <> ( docautocomplete xrn_vector_traverse  )


### xrn_matrix_traverse_pthread

**Description:**


The **xrn_matrix_traverse_pthread** is used to traverse with xoron matrix data structure with a constant computation time and multiple threads.

The function can generate $2^N$ different numbers where N is the bit width of the xnum_t data structure. 


**Function declaration:**

[comment]: <> (../inc/xrn_core.h)
```Xoronos_C
void * xrn_matrix_traverse_pthread ( 
    void * ptr 
);
```

**Arguments description:**

> **inout:**  ptr   $\rightarrow$ The ptr is a cmtraverse_t pointer with a void cast. 

[comment]: <> ( docautocomplete xrn_matrix_traverse_pthread )


## Checks Functions


### xrn_check_genesis_base

**Description:**


The **xrn_check_genesis_base** is used to check the validity of a xgenesis_base_t data structure.

If the check passes, the xgenesis_base_t can generate $2^N-1$ points.


**Function declaration:**

[comment]: <> (../inc/xrn_core.h)
```Xoronos_C
int xrn_check_genesis_base ( 
    xgenesis_base_t * gbase 
);
```

**Arguments description:**

> **input:** gbase $\rightarrow$ The genesis base pointer. 


[comment]: <> ( docautocomplete xrn_check_genesis_base   )


### xrn_matrix_compressed_check_wrapper

**Description:**


The **xrn_matrix_compressed_check_wrapper** function is used to verify the validity of the xrn_matrix_compressed_t data structure.

If the check passes, the xrn_matrix_compressed_t can generate $2^N$ points.


**Function declaration:**

[comment]: <> (../inc/xrn_core.h)
```Xoronos_C
int xrn_matrix_compressed_check_wrapper ( 
    FILE * xrn_matrix_compressed_fpr, 
    xrn_crypto_extra_settings_t settings
);
```

**Arguments description:**

> **input:** xrn_matrix_compressed_fpr $\rightarrow$ The xoron matrix compressed file pointer. \
> **inout:** settings                  $\rightarrow$ The run time settings. 

[comment]: <> ( docautocomplete xrn_matrix_compressed_check_wrapper   )


### xrn_matrix_compressed_check

**Description:**


The **xrn_matrix_compressed_check** function is used to verify the validity of the xrn_matrix_compressed_t data structure.

If the check passes, the xrn_matrix_compressed_t can generate $2^N$ points.


**Function declaration:**

[comment]: <> (../inc/xrn_core.h)
```Xoronos_C
int xrn_matrix_compressed_check ( 
    xrn_matrix_compressed_t *xmc 
);
```

**Arguments description:**

> **input:** xmc   $\rightarrow$ The xoron matrix compressed pointer. 

[comment]: <> ( docautocomplete xrn_matrix_compressed_check   )

### xrn_matrix_check_wrapper

**Description:**


The **xrn_matrix_check_wrapper** is used to verify the validity of the xrn_matrix_t data structure starting from a file pointer.

If the check passes, the xrn_matrix_t can generate $2^N$ points.

**Function declaration:**

[comment]: <> (../inc/xrn_core.h)
```Xoronos_C
int xrn_matrix_check_wrapper ( 
    FILE * xrn_matrix_fpr, 
    xrn_crypto_extra_settings_t settings 
);
```

**Arguments description:**

> **input:** xrn_matrix_fpr $\rightarrow$ The xoron matrix file pointer. \
> **inout:** settings                  $\rightarrow$ The run time settings. 

[comment]: <> ( docautocomplete xrn_matrix_check_wrapper  )

### xrn_matrix_check

**Description:**


The **xrn_matrix_check** is used to verify the validity of the xrn_matrix_t data structure.

If the check passes, the xrn_matrix_t can generate $2^N$ points.


**Function declaration:**

[comment]: <> (../inc/xrn_core.h)
```Xoronos_C
int xrn_matrix_check ( 
    xrn_matrix_t * xm 
);
```

**Arguments description:**

> **input:** xm    $\rightarrow$ The xoron matrix pointer. 

[comment]: <> ( docautocomplete xrn_matrix_check  )


## Arithmetic Functions

### xrn_doubling

**Description:**


The **xrn_doubling** operation is used to evaluate a xrn_base_t starting from a xrn_base_t data structure.


**Function declaration:**

[comment]: <> (../inc/xrn_core.h)
```Xoronos_C
void xrn_doubling ( 
    xrn_base_t * src,
    xrn_base_t * dst 
);
```

**Arguments description:**

> **input:** src   $\rightarrow$ The source xoron base pointer. \
> **output:** dst   $\rightarrow$ The destination xoron base pointer. 

[comment]: <> ( docautocomplete xrn_doubling  )

### xrn_sum_of_bases

**Description:**


The **xrn_sum_of_bases** operation is used to evaluate a xrn_base_t starting from two xrn_base_t data structures.
The operation is commutative. Therefore, the order of the input arguments is not relevant.


**Function declaration:**

[comment]: <> (../inc/xrn_core.h)
```Xoronos_C
void xrn_sum_of_bases ( 
    xrn_base_t * src0,
    xrn_base_t * src1,
    xrn_base_t * dst 
);
```

**Arguments description:**

> **input:** src0  $\rightarrow$ The first source xoron base pointer. \
> **input:** src1  $\rightarrow$ The second source xoron base pointer. \
> **output:** dst   $\rightarrow$ The destination xoron base pointer. 

[comment]: <> ( docautocomplete xrn_sum_of_bases  )

### xrn_base_number_mul

**Description:**


The **xrn_base_number_mul** operation is used to evaluate a xrn_base_t starting from a xrn_base_t and a number.


**Function declaration:**

[comment]: <> (../inc/xrn_core.h)
```Xoronos_C
void xrn_base_number_mul (
    xrn_base_t * xbase,
    xnum_t * xnum,
    xrn_base_t * dst 
);
```

**Arguments description:**

> **input:** xbase $\rightarrow$ The input xoron base pointer. \
> **input:** xnum  $\rightarrow$ The scalar number to multiply the xoron base. \
> **output:** dst   $\rightarrow$ The destination xoron base pointer. 

[comment]: <> ( docautocomplete xrn_base_number_mul  )

### xrn_dead_code

**Description:**


The **xrn_dead_code** function is used to evaluate the dead code of a xrn_base_t data structure.


**Function declaration:**

[comment]: <> (../inc/xrn_core.h)
```Xoronos_C
void xrn_dead_code ( 
    xrn_base_t * xbase,
    xnum_t * dst 
);
```


**Arguments description:**

> **input:** xbase $\rightarrow$ The input xoron base pointer. \
> **output:** dst   $\rightarrow$ The destination dead code pointer. 

[comment]: <> ( docautocomplete xrn_dead_code  )

## Xoron Matrix Compressed Functions

### xrn_matrix_decompress_wrapper

**Description:**


The **xrn_matrix_decompress_wrapper** function is used to evaluate a xrn_matrix_t starting from a file pointer storing a xrn_matrix_compressed_t data structure.


**Function declaration:**

[comment]: <> (../inc/xrn_core.h)
```Xoronos_C
int xrn_matrix_decompress_wrapper ( 
    FILE * xrn_matrix_compressed_fpr,
    FILE * xrn_matrix_decompressed_fpw,
    xrn_crypto_extra_settings_t settings
);
```

**Arguments description:**

> **input:** xrn_matrix_compressed_fpr   $\rightarrow$ The input xoron matrix compressed file pointer. \
> **output:** xrn_matrix_decompressed_fpw $\rightarrow$ The destination xoron matrix file pointer. \
> **inout:** settings                  $\rightarrow$ The run time settings. 

[comment]: <> ( docautocomplete xrn_matrix_decompress_wrapper  )


### xrn_matrix_decompress

**Description:**


The **xrn_matrix_decompress** function is used to evaluate a xrn_matrix_t starting from a xrn_matrix_compressed_t data structure.


**Function declaration:**

[comment]: <> (../inc/xrn_core.h)
```Xoronos_C
void xrn_matrix_decompress ( 
    xrn_matrix_compressed_t *xmc,
    xrn_matrix_t *xmd 
);
```

**Arguments description:**

> **input:** xmc   $\rightarrow$ The input xoron matrix compressed pointer. \
> **output:** xmd   $\rightarrow$ The destination xoron matrix pointer. 

[comment]: <> ( docautocomplete xrn_matrix_decompress  )


### xrn_matrix_compressed_permute_wrapper

**Description:**


The **xrn_matrix_compressed_permute_wrapper** function is used to randomly change the xrn_matrix_compressed_t data structure, starting from a file pointer.

**Function declaration:**

[comment]: <> (../inc/xrn_core.h)
```Xoronos_C
int xrn_matrix_compressed_permute_wrapper (
    FILE * xrn_matrix_compressed_fpr, 
    FILE * xrn_matrix_compressed_fpw,
    xrn_crypto_extra_settings_t settings
);
```

**Arguments description:**

> **input:** xrn_matrix_compressed_fpr $\rightarrow$ The input xoron matrix compressed file pointer. \
> **output:** xrn_matrix_compressed_fpw $\rightarrow$ The output xoron matrix compressed file pointer. \
> **inout:** settings                  $\rightarrow$ The run time settings. 

[comment]: <> ( docautocomplete xrn_matrix_compressed_permute_wrapper  )

### xrn_matrix_compressed_permute

**Description:**


The **xrn_matrix_compressed_permute** function is used to randomly change the xrn_matrix_compressed_t data structure.

**Function declaration:**

[comment]: <> (../inc/xrn_core.h)
```Xoronos_C
int xrn_matrix_compressed_permute( 
    xrn_matrix_compressed_t * xmc 
);
```

**Arguments description:**

> **inout:**  xmc   $\rightarrow$ The input xoron matrix compressed pointer. 

[comment]: <> ( docautocomplete xrn_matrix_compressed_permute )

## Comparison Functions

### xrn_compare_genesis_bases

**Description:**

The **xrn_compare_genesis_bases** function is used to check the equivalency of two xgenesis_base_t data structures.

**Function declaration:**

[comment]: <> (../inc/xrn_core.h)
```Xoronos_C
int xrn_compare_genesis_bases ( 
    xgenesis_base_t * src0,
    xgenesis_base_t * src1 
);
```

**Arguments description:**

> **input:** src0  $\rightarrow$ The first xoron genesis pointer. \
> **input:** src1  $\rightarrow$ The second xoron genesis pointer. 

[comment]: <> ( docautocomplete xrn_compare_genesis_bases  )


### xrn_permute_matrix

**Description:**

The **xrn_permute_matrix** function is used to randomly change the xrn_matrix_compressed_t data structure.

**Function declaration:**

[comment]: <> (../inc/xrn_core.h)
```Xoronos_C
int xrn_permute_matrix ( 
    xrn_matrix_t * xm 
);
```

**Arguments description:**

> **inout:**  xm    $\rightarrow$ The input xoron matrix compressed pointer. 

[comment]: <> ( docautocomplete xrn_permute_matrix )

## Comparison Functions

### xrn_compare_genesis_bases

**Description:**

The **xrn_compare_genesis_bases** function is used to check the equivalency of two xgenesis_base_t data structures.

**Function declaration:**

[comment]: <> (../inc/xrn_core.h)
```Xoronos_C
int xrn_compare_genesis_bases ( 
    xgenesis_base_t * src0,
    xgenesis_base_t * src1 
);
```

**Arguments description:**

> **input:** src0  $\rightarrow$ The first xoron genesis pointer. \
> **input:** src1  $\rightarrow$ The second xoron genesis pointer. 

[comment]: <> ( docautocomplete xrn_compare_genesis_bases  )

### xrn_compare_bases

**Description:**

The **xrn_compare_bases** function is used to check the equivalency of two xrn_base_t data structures.

**Function declaration:**

[comment]: <> (../inc/xrn_core.h)
```Xoronos_C
int xrn_compare_bases ( 
    xrn_base_t * src0,
    xrn_base_t * src1 
);
```

**Arguments description:**

> **input:** src0  $\rightarrow$ The first xoron base pointer. \
> **input:** src1  $\rightarrow$ The second xoron base pointer. 

[comment]: <> ( docautocomplete xrn_compare_bases  )

### xrn_compare_vectors

**Description:**

The **xrn_compare_vectors** function is used to check the equivalency of two xrn_vector_t data structures.

**Function declaration:**

[comment]: <> (../inc/xrn_core.h)
```Xoronos_C
int xrn_compare_vectors ( 
    xrn_vector_t * src0,
    xrn_vector_t * src1 
);
```

**Arguments description:**

> **input:** src0  $\rightarrow$ The first xoron vector pointer. \
> **input:** src1  $\rightarrow$ The second xoron vector pointer. 

[comment]: <> ( docautocomplete xrn_compare_vectors  )


### xrn_compare_matrices

**Description:**

The **xrn_compare_matrices** function is used to check the equivalency of two xrn_matrix_t data structures.

**Function declaration:**

[comment]: <> (../inc/xrn_core.h)
```Xoronos_C
int xrn_compare_matrices ( 
    xrn_matrix_t * src0,
    xrn_matrix_t * src1 
);
```

**Arguments description:**

> **input:** src0  $\rightarrow$ The first xoron matrix pointer. \
> **input:** src1  $\rightarrow$ The second xoron matrix pointer. 

[comment]: <> ( docautocomplete xrn_compare_matrices  )


### xrn_compare_matrices_compressed

**Description:**

The **xrn_compare_matrices** is used to check the equivalency of two xrn_matrix_compressed_t data structures.

**Function declaration:**

[comment]: <> (../inc/xrn_core.h)
```Xoronos_C
int xrn_compare_matrices_compressed ( 
    xrn_matrix_compressed_t * src0,
    xrn_matrix_compressed_t * src1 
);
```

**Arguments description:**

> **input:** src0  $\rightarrow$ The first xoron matrix compressed pointer. \
> **input:** src1  $\rightarrow$ The second xoron matrix compressed pointer. 

[comment]: <> ( docautocomplete xrn_compare_matrices_compressed  )

## Initialization Functions

### initialize_xpoint

**Description:**

The **initialize_xpoint** function is used to initialize the xrn_point_t data structure to zero.

**Function declaration:**

[comment]: <> (../inc/xrn_core.h)
```Xoronos_C
void xrn_initialize_point ( 
    xrn_point_t * dst 
);
```

**Arguments description:**

> **output:** dst   $\rightarrow$ The destination xrn_point_t pointer. 

[comment]: <> ( docautocomplete xrn_initialize_point )

### xrn_initialize_genesis_base

**Description:**

The **xrn_initialize_genesis_base** function is used to initialize the xgenesis_base_t data structure to zero.

**Function declaration:**

[comment]: <> (../inc/xrn_core.h)
```Xoronos_C
void xrn_initialize_genesis_base ( 
    xgenesis_base_t * dst 
);
```

**Arguments description:**

> **output:** dst   $\rightarrow$ The destination xoron genesis base pointer. 

[comment]: <> ( docautocomplete xrn_initialize_genesis_base  )

### xrn_initialize_base

**Description:**

The **xrn_initialize_base** function is used to initialize the xrn_base_t data structure to zero.

**Function declaration:**

[comment]: <> (../inc/xrn_core.h)
```Xoronos_C
void xrn_initialize_base ( 
    xrn_base_t * dst 
);
```

**Arguments description:**

> **output:** dst   $\rightarrow$ The destination xoron base pointer. 

[comment]: <> ( docautocomplete xrn_initialize_base  )

### xrn_initialize_vector

**Description:**

The **xrn_initialize_vector** function is used to initialize the xrn_vector_t data structure to zero.

**Function declaration:**

[comment]: <> (../inc/xrn_core.h)
```Xoronos_C
void xrn_initialize_vector ( 
    xrn_vector_t * dst 
);
```

**Arguments description:**

> **output:** dst   $\rightarrow$ The destination xoron vector pointer. 

[comment]: <> ( docautocomplete xrn_initialize_vector  )

### xrn_initialize_matrix

**Description:**

The **xrn_initialize_matrix** function is used to initialize the xrn_matrix_t data structure to zero.

**Function declaration:**

[comment]: <> (../inc/xrn_core.h)
```Xoronos_C
void xrn_initialize_matrix ( 
    xrn_matrix_t * dst 
);
```

**Arguments description:**

> **output:** dst   $\rightarrow$ The destination xoron matrix pointer. 

[comment]: <> ( docautocomplete xrn_initialize_matrix  )


### xrn_initialize_matrix_compressed

**Description:**

The **xrn_initialize_matrix_compressed** function is used to initialize the xrn_matrix_compressed_t data structure to zero.

**Function declaration:**

[comment]: <> (../inc/xrn_core.h)
```Xoronos_C
void xrn_initialize_matrix_compressed ( 
    xrn_matrix_compressed_t * dst 
);
```

**Arguments description:**

> **output:** dst   $\rightarrow$ The destination xoron matrix pointer. 

[comment]: <> ( docautocomplete xrn_initialize_matrix_compressed  )

## Generation Functions

### xrn_make_point

**Description:**

The **xrn_make_point** function is used to generate xrn_point_t data structure.

**Function declaration:**

[comment]: <> (../inc/xrn_core.h)
```Xoronos_C
int xrn_make_point (
    xrn_point_t * point,
    char rnd_str[XRN_BUFF_SIZE]
); 
```

**Arguments description:**

> **output:** point    $\rightarrow$ The point pointer. \
> **input:** rnd_str  $\rightarrow$ A random string affecting the randomicity. 

[comment]: <> ( docautocomplete xrn_make_point  )


### xrn_make_point_wrapper

**Description:**

The **xrn_make_point_wrapper** function is used to generate a file storing a xrn_point_t data structure.

**Function declaration:**

[comment]: <> (../inc/xrn_core.h)
```Xoronos_C
int xrn_make_point_wrapper ( 
    FILE * point_fpw,
    xrn_crypto_extra_settings_t  settings
); 
```

**Arguments description:**

> **output:** point_fpw   $\rightarrow$ The point file pointer. \
> **input:** settings    $\rightarrow$ The encoding settings.

[comment]: <> ( docautocomplete xrn_make_point_wrapper  )


## Storing Functions

### xrn_dump_point

**Description:**

The **xrn_dump_point** function is used to write the xrn_point_t data structure into a file.
The function implements data integrity check.

**Function declaration:**

[comment]: <> (../inc/xrn_core.h)
```Xoronos_C
int xrn_dump_point ( 
    xrn_point_t point,
    FILE * fpw,
    xrn_crypto_extra_settings_t settings
);
```

**Arguments description:**

> **input:** point        $\rightarrow$ The point value. \
> **output:** fpw          $\rightarrow$ The destination file pointer. \
> **inout:** settings                  $\rightarrow$ The run time settings. 

[comment]: <> ( docautocomplete xrn_dump_point  )

### xrn_dump_genesis_base

**Description:**

The **xrn_dump_genesis_base** function is used to store the xgenesis_base_t data structure in a binary file.
The function implements data integrity check.

**Function declaration:**

[comment]: <> (../inc/xrn_core.h)
```Xoronos_C
int xrn_dump_genesis_base ( 
    xgenesis_base_t * src,
    FILE * fp,
    xrn_crypto_extra_settings_t settings
);
```

**Arguments description:**

> **input:** src          $\rightarrow$ The xoron genesis base pointer. \
> **output:** fp           $\rightarrow$ The destination file pointer. \
> **inout:** settings                  $\rightarrow$ The run time settings. 

[comment]: <> ( docautocomplete xrn_dump_genesis_base  )

### xrn_dump_base

**Description:**

The **xrn_dump_base** function is used to store the xrn_base_t data structure in a binary file.
The function implements data integrity check.

**Function declaration:**

[comment]: <> (../inc/xrn_core.h)
```Xoronos_C
int xrn_dump_base ( 
    xrn_base_t * src,
    FILE * fp,
    xrn_crypto_extra_settings_t settings
);
```

**Arguments description:**

> **input:** src          $\rightarrow$ The xoron base pointer. \
> **output:** fp           $\rightarrow$ The destination file pointer. \
> **inout:** settings                  $\rightarrow$ The run time settings. 

[comment]: <> ( docautocomplete xrn_dump_base  )

### xrn_dump_vector

**Description:**

The **xrn_dump_vector** function is used to store the xrn_vector_t data structure in a binary file.
The function implements data integrity check.

**Function declaration:**

[comment]: <> (../inc/xrn_core.h)
```Xoronos_C
int xrn_dump_vector ( 
    xrn_vector_t * src,
    FILE * fp,
    xrn_crypto_extra_settings_t settings
);
```

**Arguments description:**

> **input:** src          $\rightarrow$ The xoron vector pointer. \
> **output:** fp           $\rightarrow$ The destination file pointer. \
> **inout:** settings                  $\rightarrow$ The run time settings. 

[comment]: <> ( docautocomplete xrn_dump_vector  )


### xrn_dump_matrix

**Description:**

The **xrn_dump_matrix** function is used to store the xrn_matrix_t data structure in a binary file.
The function implements data integrity check.

**Function declaration:**

[comment]: <> (../inc/xrn_core.h)
```Xoronos_C
int xrn_dump_matrix ( 
    xrn_matrix_t * src,
    FILE * fp,
    xrn_crypto_extra_settings_t settings
);
```

**Arguments description:**

> **input:** src          $\rightarrow$ The xoron matrix pointer. \
> **output:** fp           $\rightarrow$ The destination file pointer. \
> **inout:** settings                  $\rightarrow$ The run time settings. 

[comment]: <> ( docautocomplete xrn_dump_matrix  )


### xrn_dump_matrix_compressed

**Description:**

The **xrn_dump_matrix_compressed** function is used to store the xrn_matrix_compressed_t data structure in a binary file.
The function implements data integrity check.

**Function declaration:**

[comment]: <> (../inc/xrn_core.h)
```Xoronos_C
int xrn_dump_matrix_compressed ( 
    xrn_matrix_compressed_t * src,
    FILE * fp,
    xrn_crypto_extra_settings_t settings
);
```

**Arguments description:**

> **input:** src          $\rightarrow$ The xoron matrix compressed pointer. \
> **output:** fp           $\rightarrow$ The destination file pointer. \
> **inout:** settings                  $\rightarrow$ The run time settings. 

[comment]: <> ( docautocomplete xrn_dump_matrix_compressed  )

## Loading Functions

### xrn_get_library_version

**Description:**

The **xrn_get_library_version** is used to get the library version.

**Function declaration:**

[comment]: <> (../inc/xrn_core.h)
```Xoronos_C
int xrn_get_library_version ( 
); 
```

### xrn_load_default_settings

**Description:**

The **xrn_load_default_settings** is used to initialize run time settings with default values.

**Function declaration:**

[comment]: <> (../inc/xrn_core.h)
```Xoronos_C
int xrn_load_default_settings ( 
    xrn_crypto_extra_settings_t  * settings 
); 
```

**Arguments description:**

> **inout:** settings $\rightarrow$ The run time settings. 

[comment]: <> ( docautocomplete xrn_load_default_settings )


### xrn_load_point

**Description:**

The **xrn_load_point** function is used to parse a file and store the content in the xrn_point_t data structure.
The function implements data integrity check.

**Function declaration:**

[comment]: <> (../inc/xrn_core.h)
```Xoronos_C
int xrn_load_point ( 
    xrn_point_t * point,
    FILE * fpr,
    xrn_crypto_extra_settings_t settings
);
```

**Arguments description:**

> **output:** point        $\rightarrow$ The point pointer. \
> **input:** fpr          $\rightarrow$ The source file pointer. \
> **inout:** settings                  $\rightarrow$ The run time settings. 

[comment]: <> ( docautocomplete xrn_load_point  )

### xrn_load_genesis_base

**Description:**

The **xrn_load_genesis_base** function is used to parse a binary file and store the content in the xgenesis_base_t data structure.
The function implements data integrity check.

**Function declaration:**

[comment]: <> (../inc/xrn_core.h)
```Xoronos_C
int xrn_load_genesis_base ( 
    FILE * fp,
    xgenesis_base_t * dst,
    xrn_crypto_extra_settings_t settings
);
```

**Arguments description:**

> **input:** fp           $\rightarrow$ The source file pointer. \
> **output:** dst          $\rightarrow$ The xoron genesis base pointer. \
> **inout:** settings                  $\rightarrow$ The run time settings. 

[comment]: <> ( docautocomplete xrn_load_genesis_base  )

### xrn_load_base

**Description:**

The **xrn_load_base** function is used to parse a binary file and store the content in the xrn_base_t data structure.
The function implements data integrity check.

**Function declaration:**

[comment]: <> (../inc/xrn_core.h)
```Xoronos_C
int xrn_load_base ( 
    FILE * fp,
    xrn_base_t * dst,
     xrn_crypto_extra_settings_t settings
);
```

**Arguments description:**

> **input:** fp           $\rightarrow$ The source file pointer. \
> **output:** dst          $\rightarrow$ The xoron base pointer. \
> **inout:** settings                  $\rightarrow$ The run time settings. 

[comment]: <> ( docautocomplete xrn_load_base  )


### xrn_load_vector

**Description:**

The **xrn_load_vector** function is used to parse a binary file and store the content in the xrn_vector_t data structure.
The function implements data integrity check.


**Function declaration:**

[comment]: <> (../inc/xrn_core.h)
```Xoronos_C
int xrn_load_vector ( 
    FILE * fp,
    xrn_vector_t * dst,
    xrn_crypto_extra_settings_t settings
);
```

**Arguments description:**

> **input:** fp           $\rightarrow$ The source file pointer. \
> **output:** dst          $\rightarrow$ The xoron vector pointer. \
> **inout:** settings                  $\rightarrow$ The run time settings. 

[comment]: <> ( docautocomplete xrn_load_vector  )

### xrn_load_matrix

**Description:**

The **xrn_load_matrix** function is used to parse a binary file and store the content in the xrn_matrix_t data structure.
The function implements data integrity check.


**Function declaration:**

[comment]: <> (../inc/xrn_core.h)
```Xoronos_C
int xrn_load_matrix ( 
    FILE * fp,
    xrn_matrix_t * src,
    xrn_crypto_extra_settings_t settings
);
```

**Arguments description:**

> **input:** fp           $\rightarrow$ The source file pointer. \
> **output:** dst          $\rightarrow$ The xoron matrix pointer. \
> **inout:** settings                  $\rightarrow$ The run time settings. 

[comment]: <> ( docautocomplete xrn_load_matrix  )

### xrn_load_matrix_compressed

**Description:**

The **xrn_load_matrix_compressed** function is used to parse a binary file and store the content in the xrn_load_matrix_compressed_t data structure.
The function implements data integrity check.

**Function declaration:**

[comment]: <> (../inc/xrn_core.h)
```Xoronos_C
int xrn_load_matrix_compressed ( 
    FILE * fp,
    xrn_matrix_compressed_t * src,
    xrn_crypto_extra_settings_t settings
);
```

**Arguments description:**

> **input:** fp           $\rightarrow$ The source file pointer. \
> **output:** dst          $\rightarrow$ The compressed xoron matrix pointer. \
> **inout:** settings                  $\rightarrow$ The run time settings. 

[comment]: <> ( docautocomplete xrn_load_matrix_compressed  )

### xrn_load_header_file

**Description:**

The **xrn_load_header_file** is used to get the header of a file generated by the Xoron library.

**Function declaration:**

[comment]: <> (../inc/xrn_core.h)
```Xoronos_C
int xrn_load_header_file( 
    FILE * fpi,
    uint8_t * crc_bytes,
    xrn_lib_xtype_t * type,
    xrn_lib_xtype_t exp_type,
    uint8_t * state_size,
    uint32_t * reserved_0,
    uint32_t * reserved_1,
    xrn_encoding_param_t * enc_param,
    xrn_crypto_extra_settings_t settings
);
```

**Arguments description:**

> **input:** fpi              $\rightarrow$ The input file pointer. \
> **output:** crc_bytes        $\rightarrow$ The stored crc size in the header. \
> **output:** type             $\rightarrow$ The type stored in the header. \
> **input:** exp_type         $\rightarrow$ The expected file type in the header. \
> **output:** state_size       $\rightarrow$ The state size info stored in the header. \
> **output:** reserved_0       $\rightarrow$ The the first reserved field in the header. \
> **output:** reserved_1       $\rightarrow$ The the second reserved field in the header. \
> **output:** enc_param        $\rightarrow$ The encoding parameters. \
> **inout:** settings                  $\rightarrow$ The run time settings. 

[comment]: <> ( docautocomplete xrn_load_header_file )


### xrn_load_header_bytes

**Description:**

The **xrn_load_header_bytes** is used to get the header of a stream of bytes generated by the Xoron library.

**Function declaration:**

[comment]: <> (../inc/xrn_core.h)
```Xoronos_C
int xrn_load_header_bytes ( 
    uint8_t * in_bytes,
    uint64_t in_bytes_length,
    uint8_t * crc_bytes,
    xrn_lib_xtype_t * type,
    xrn_lib_xtype_t exp_type,
    uint8_t * state_size,
    uint64_t * index,
    uint32_t * reserved_0,
    uint32_t * reserved_1,
    xrn_encoding_param_t * enc_param,
    xrn_crypto_extra_settings_t settings
);
```

**Arguments description:**

> **input:** in_bytes         $\rightarrow$ The input stream of bytes. \
> **input:** in_bytes_length  $\rightarrow$ The length of the stream of bytes. \
> **output:** crc_bytes        $\rightarrow$ The stored crc size in the header. \
> **output:** type             $\rightarrow$ The type stored in the header. \
> **input:** exp_type         $\rightarrow$ The expected file type in the header. \
> **output:** state_size       $\rightarrow$ The state size info stored in the header. \
> **output:** index            $\rightarrow$ The current index of the out_bytes. \
> **output:** reserved_0       $\rightarrow$ The the first reserved field in the header. \
> **output:** reserved_1       $\rightarrow$ The the second reserved field in the header. \
> **output:** enc_param        $\rightarrow$ The encoding parameters. \
> **output:** header           $\rightarrow$ The output header. \
> **inout:** settings          $\rightarrow$ The run time settings. 

[comment]: <> ( docautocomplete xrn_load_header_bytes )


### xrn_initialize_header

**Description:**

The **xrn_initialize_header** is used to create an initialized xrn_crypto_lib_header_t data structure.

**Function declaration:**

[comment]: <> (../inc/xrn_core.h)
```Xoronos_C
int xrn_initialize_header ( 
    xrn_lib_xtype_t type,
    uint8_t crc_bytes,
    uint8_t state_size,
    uint32_t component_id,
    xrn_crypto_lib_header_t * header
);
```

**Arguments description:**

> **input:** type             $\rightarrow$ The type to be stored in the header. \
> **input:** crc_bytes        $\rightarrow$ The crc size to be stored in the header. \
> **input:** state_size       $\rightarrow$ The state size to store in the header. \
> **input:** component_id     $\rightarrow$ The component id is an optional input to be set by the host program calling the library. \
> **output:** header          $\rightarrow$ The initialized header. \

[comment]: <> ( docautocomplete xrn_initialize_header )


### xrn_dump_header_file

**Description:**

The **xrn_dump_header_file** is used to dump the header of a file generated by the Xoron library.

**Function declaration:**

[comment]: <> (../inc/xrn_core.h)
```Xoronos_C
int xrn_dump_header_file ( 
    FILE * fpo,
    xrn_lib_xtype_t type,
    uint8_t crc_bytes,
    uint8_t state_size,
    xrn_encoding_param_t * enc_param,
    xrn_crypto_extra_settings_t settings
);
```

**Arguments description:**

> **output:** fpo             $\rightarrow$ The input file pointer. \
> **input:** type             $\rightarrow$ The type to be stored in the header. \
> **input:** crc_bytes        $\rightarrow$ The crc size to be stored in the header. \
> **input:** state_size       $\rightarrow$ The state size to store in the header. \
> **output:** enc_param       $\rightarrow$ The encoding parameters. \
> **inout:** settings                  $\rightarrow$ The run time settings. 

[comment]: <> ( docautocomplete xrn_dump_header_file )


### xrn_dump_header_bytes

**Description:**

The **xrn_dump_header_bytes** is used to dump the header of a file generated by the Xoron library.

**Function declaration:**

[comment]: <> (../inc/xrn_core.h)
```Xoronos_C
int xrn_dump_header_bytes( 
    uint8_t * out_bytes, 
    uint64_t out_bytes_length,
    xrn_lib_xtype_t type,
    uint8_t crc_bytes,
    uint8_t state_size,
    uint64_t * index,
    xrn_encoding_param_t * enc_param,
    xrn_crypto_extra_settings_t settings
);
```

**Arguments description:**

> **input:** out_bytes        $\rightarrow$ The output stream of bytes. \
> **input:** out_bytes_length $\rightarrow$ The length of the stream of bytes. \
> **input:** type             $\rightarrow$ The type to be stored in the header. \
> **input:** crc_bytes        $\rightarrow$ The crc size to be stored in the header. \
> **input:** state_size       $\rightarrow$ The state size to store in the header. \
> **output:** index            $\rightarrow$ The current index of the out_bytes. \
> **output:** enc_param        $\rightarrow$ The encoding parameters. \
> **inout:** settings                  $\rightarrow$ The run time settings. 

[comment]: <> ( docautocomplete xrn_dump_header_bytes )

## End of the library

[comment]: <> (../inc/xrn_core.h)
```Xoronos_C
#endif
```

